import 'package:base_flutter/base_flutter.dart';

import '../../model/drop_data_model.dart';

class FloorListEntity {
  List<FloorEntity>? rows;

  FloorListEntity({
    this.rows,
  });

  factory FloorListEntity.fromJson(Map<String, dynamic> json) {
    final originList = json['rows'] as List?;
    List<FloorEntity> protocolList =
        (originList??[]).map((value) => FloorEntity.fromJson(value)).toList();
    return FloorListEntity(
      rows: protocolList,
    );
  }
}

class FloorEntity extends IDropDataModel implements IPickerData {
  int? id;
  List<FloorInfo>? floorList;
  String? buildingNo;

  FloorEntity({
    this.floorList,
    this.id,
    this.buildingNo
  });

  factory FloorEntity.fromJson(Map<String, dynamic> json) {
    final originList = json['floorList']!=null?(json['floorList'] as List):[];
    List<FloorInfo> protocolList =
        originList.map((value) => FloorInfo.fromJson(value)).toList();
    return FloorEntity(
      floorList: protocolList,
      id: json["id"],
      buildingNo: json["buildingNo"],
    );
  }

  @override
  String get iId => id==null?"":id.toString();

  @override
  String get iName => buildingNo??"";

  @override
  String get name => buildingNo??"";

  @override
  set name(String _name) {
  }

  FloorEntity copy(){
    return FloorEntity(
      id:  this.id,
      floorList: this.floorList,
      buildingNo: this.buildingNo,
    );
  }


}

class FloorInfo extends IDropDataModel implements IPickerData {
  String? floorNo;
  int? id;
  bool isSelected = false;

  FloorInfo({
    this.id,
    this.floorNo,
    this.isSelected = false,
  });

  FloorInfo.fromJson(Map data) {
    id = data['id'];
    floorNo = data['floorNo'];
    isSelected = data['isSelected'] = false;
  }

  @override
  String get iId => id==null?"":id.toString();

  @override
  String get iName => floorNo??"";

  @override
  String get name => floorNo??"";

  @override
  set name(String _name) {
  }

}
